//
//  MeOrderCell.m
//  ai2ban
//
//  Created by Heartbeats on 2018/1/7.
//  Copyright © 2018年 mac book pro. All rights reserved.
//

#import "MeOrderCell.h"
#import "OrderProductView.h" 

@interface MeOrderCell()
@property (weak, nonatomic) IBOutlet UILabel *orderNumberLab;
@property (weak, nonatomic) IBOutlet UILabel *actualPayNumberLab;
@property (weak, nonatomic) IBOutlet UILabel *getHowSocreNumberLab;
@property (weak, nonatomic) IBOutlet UILabel *orderStateLab;
@property (weak, nonatomic) IBOutlet UIView *productBgView;
@property (weak, nonatomic) IBOutlet UIButton *actionBtnOne;
@property (weak, nonatomic) IBOutlet UIButton *actionBtnTwo;


@end

@implementation MeOrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.actionBtnOne.layer.cornerRadius = 4;
    self.actionBtnOne.layer.borderColor = [RGBA(0, 0, 0, 0.6) CGColor];
    self.actionBtnOne.layer.borderWidth = 1;
    self.actionBtnTwo.layer.cornerRadius = 4;
    self.actionBtnTwo.layer.borderColor = [RGBA(0, 0, 0, 0.6) CGColor];
    self.actionBtnTwo.layer.borderWidth = 1;
}
- (void)prepareForReuse {
    [super prepareForReuse];
    for (UIView *view in self.productBgView.subviews) {
        [view removeFromSuperview];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

- (void)setOrderModel:(OrderModel *)orderModel {
    _orderModel = orderModel;
    self.actualPayNumberLab.text = [NSString stringWithFormat:@"实付: ¥%@", orderModel.orderScore];
    if ([orderModel.orderType intValue] <= 2) {
        self.getHowSocreNumberLab.text = @"";
    }else {
        self.getHowSocreNumberLab.text = [NSString stringWithFormat:@"获得%@积分", orderModel.orderScore];
    }
    switch ([orderModel.orderStatus intValue]) {
        case -1:
            self.orderStateLab.text = @"已取消"; break;
        case 0:
            self.orderStateLab.text = @"待付款"; break;
        case 1:
            self.orderStateLab.text = @"未使用"; break;
        case 2:
            self.orderStateLab.text = @"已使用"; break;
        case 3:
            self.orderStateLab.text = @"已退款"; break;
        default:
            break;
    }
    self.orderNumberLab.text = [NSString stringWithFormat:@"%@", orderModel.sellerName];
    
    int i = 0;
    for (ProductModel *model in self.orderModel.productList) {
        OrderProductView *productView = LOADNIB(@"OrderProductView");
        productView.prodModel = model;
        [productView setY:i * 90];
        [productView setX:0];
        [productView setHeight:90];
        [productView setWidth:self.mj_w];
        [self.productBgView addSubview: productView];
        ++i;
    }
}
@end
